package com.sghd.charge.module.order.repository;

import com.sghd.charge.module.model.ChannelType;
import com.sghd.charge.module.order.entity.Order;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import org.springframework.data.repository.query.Param;

import java.util.List;

/**
 * @author frank
 */
public interface OrderRepository extends PagingAndSortingRepository<Order, Long> {

    /**
     * 查询自动补单的
     * @return
     */
    @Query(value = "from Order o where o.state='WAIT'")
    List<Order> findWait();

    /**
     * 根据交易平台和流水号查询
     * @param transactionId 流水号
     * @param channelType 平台
     * @return
     */
    @Query(value = "from Order o where o.channel=:channelType and o.transactionNumber=:transactionId")
    List<Order> findByTransactionId(@Param("channelType") ChannelType channelType, @Param("transactionId") String transactionId);
}
